package com.mec.web.y2012.ajax;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.mec.web.y2012.coreservlet.Constants;
import com.mec.web.y2012.coreservlet.ServletUtilities;

/**
 * Servlet implementation class HelloAjaxServlet
 */
@WebServlet("/ajax/helloAjax/")
public class HelloAjaxServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public HelloAjaxServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		
		//
		String title = "Hello Ajax.";
		out.println(Constants.docType +ServletUtilities.headWithTitle(title));
		out.println("<body>");
		out.println("<h1>" + title +"</h1>");
		out.println("<hr/>");
		out.println("<p>param=" + request.getParameter("param") + "</p>");
		out.println("</body></html>");
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

	private static final Logger logger = 
			Logger.getLogger(HelloAjaxServlet.class);
}
